//
//  XFMainViewController.swift
//  mxfweibo
//
//  Created by apple1 on 15/12/15.
//  Copyright © 2015年 莫祥富. All rights reserved.
//

import UIKit

class XFMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let mainTabbar = XFMainTabbar()
        setValue(mainTabbar, forKey: "tabBar")
        
        let homeVc = XFHomeViewController()
        self.addChildVc(homeVc, title: "首页", imageName:"tabbar_home")
        
        let messageVc = XFMessageViewController()
        self.addChildVc(messageVc, title: "消息", imageName:"tabbar_message_center")
        
        let discoveryVc = XFDiscoveryViewController()
        self.addChildVc(discoveryVc, title: "发现", imageName: "tabbar_discover")
        
        let profileVc = XFProfileViewController()
        self.addChildVc(profileVc, title: "我", imageName: "tabbar_profile")
 
    }
    
    private func addChildVc(controller:UIViewController,title:String,imageName:String)
    {
        self.addChildViewController(UINavigationController(rootViewController: controller))
        
        controller.title = title
        controller.tabBarItem.image = UIImage(named: imageName)
        
        let highLightedName = imageName + "_highlighted"
        
        controller.tabBarItem.selectedImage = UIImage(named: highLightedName)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: UIControlState.Selected)
        
        
    }

   
}
